<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
 *日志记录模块
 *作者：seven
 *qq:397109515
 *email:mike859@qq.com
 */
class Qq_chats_model extends MY_Model{
	const DB = 'qq_chats';
	public function __construct()
	{
		parent::__construct();
	}
	/*
	 *返回日志列表信息
	 *@param array where 查找的条件
	 *@param int limit 查找开始的id limit 第一个参数
	 *@param int limit_number 显示的数量
	 *@param string select 需要查找的字段
	 *@param join_table join表
	 *@param join_where join条件
	 *param array data 
	 *return array
	 */
	public function lists($where = array(),$limit = false,$limit_number = false,$select = '*',$join_table = false,$join_where = false)
	{
		foreach($where as $id=>$item){
			$this->db->where($id,$item);	
		}
		if($limit !== false)
		{
			if($limit_number !== false)
			{
				$this->db->limit($limit_number,$limit);
			}
			else
			{
				$this->db->limit($limit);
			}
		}
		if($join_table !== false and $join_where !== false)
		{
			$this->db->join($join_table, $join_where);
		}

		$this->db->select($select);
		$this->db->from(self::DB);
		$query = $this->db->get();
		return $query->result();
	}
	
	/*
	 *记录日志
	 *param title 日志类型
	 *param data 日志内容
	 */
	public function add($msg_id,$from_uin,$to_uin,$msg_id2,$msg_type,$reply_ip,$time,$content,$msg,$type)
	{
		$data['msg_id'] = $msg_id;
		$data['from_uin'] = $from_uin;
		$data['to_uin'] = $to_uin;
		$data['msg_id2'] = $msg_id2;
		$data['msg_type'] = $msg_type;
		$data['reply_ip'] = $reply_ip;
		$data['time'] = $time;
        $data['msg'] = $msg;
		$data['content'] = $content;
		$data['poll_type'] = $type;
		return $this->db->insert(self::DB,$data);
	}
}








